

    $('#btn-photo').click(function(event) {
      
       // Grab elements, create settings, etc.
      var canvas = document.getElementById("canvas"),
      context = canvas.getContext("2d"),
      video = document.getElementById("video"),
      videoObj = { "video": true },
      errBack = function(error) 
      {
        console.log("Video capture error: ", error.code); 
      };

      // Put video listeners into place
      if(navigator.getUserMedia) 
      { // Standard
        navigator.getUserMedia(videoObj, function(stream) 
        {
          video.src = stream;
          video.play();
        }, errBack);
      } 
      else if(navigator.webkitGetUserMedia) 
      { // WebKit-prefixed
        navigator.webkitGetUserMedia(videoObj, function(stream)
        {
          video.src = window.webkitURL.createObjectURL(stream);
          video.play();
        }, errBack);
      }


      $('#snap').click(function(event) {
        
         context.drawImage(video, 0, 0, 80, 80);

        // save canvas image as data url (png format by default)
        var dataURL = canvas.toDataURL();

        // alert(dataURL);

        // set canvasImg image src to dataURL
        // so it can be saved as an image
        $('#canvasImg').attr({
          src: dataURL
        });
        
        $('#txt-url').val(dataURL);       
      });
    });
